#define  _CRT_SECURE_NO_WARNINGS 1

#include "Heap.h"

void TestHeap()
{
	Heap hp;
	HeapInit(&hp);
	HeapPush(&hp, 5);
	HeapPush(&hp, 2);
	HeapPush(&hp, 3);
	HeapPush(&hp, 8);
	HeapPush(&hp, 7);
	HeapPush(&hp, 1);
	printf("HeapSize: %d\n", HeapSize(&hp));
	HeapShow(&hp);

	/*HeapPop(&hp);
	HeapShow(&hp);

	HeapPop(&hp);
	HeapShow(&hp);

	HeapPop(&hp);
	HeapShow(&hp);

	HeapPop(&hp);
	HeapShow(&hp);

	HeapPop(&hp);
	HeapShow(&hp);

	HeapPop(&hp);
	HeapShow(&hp);*/
	while (!HeapEmpty(&hp))
	{
		printf("%d ", HeapTop(&hp));
		HeapPop(&hp);
	}
	printf("\n");

	HeapDestory(&hp);
}

void TestHeapSort()
{
	HDataType arr[] = { 63,84,98,55,12,14,1,6,8,7,1,41,111,999,777,444,5,6 };
	int size = sizeof(arr) / sizeof(arr[0]);
	for (int i = 0; i < size; i++)
	{
		printf("%d ", arr[i]);
	}
	printf("\n");
	HeapSort(arr, size);
	for (int i = 0; i < size; i++)
	{
		printf("%d ", arr[i]);
	}
	printf("\n");

}

int main()
{
	//TestHeap();
	TestHeapSort();

	return 0;
}